package com.wc.AlgoOJ._DFS.AG0301;

import java.io.*;
import java.util.StringTokenizer;

/**
 * @Author congege
 * @Description 迷宫漫步
 * http://43.138.190.70:8888/p/AG0301
 * @Date Created in 2023/12/20-10:48
 */
public class Main {
    static FastReader in = new FastReader();
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static int ans = 0;
    static int w, h;
    static char[][] map;
    static boolean[][] vis;
    static int startX, startY;
    static int[] positionX = new int[]{-1, 0, 1, 0};
    static int[] positionY = new int[]{0, 1, 0, -1};

    public static void main(String[] args) {
        while (true) {
            // 标记自己
            ans = 1;
            w = in.nextInt();
            h = in.nextInt();
            if (w == 0 && h == 0) {
                break;
            }
            map = new char[h][w];
            vis = new boolean[h][w];

            for (int i = 0; i < h; i++) {
                String s = in.nextLine();
                int st = s.indexOf('@');
                if (st != -1) {
                    startX = i;
                    startY = st;
                }
                map[i] = s.toCharArray();
            }
            dfs(startX, startY);
            out.println(ans);
        }
        out.flush();
    }

    static void dfs(int x, int y) {
        vis[x][y] = true;
        for (int i = 0; i < 4; i++) {
            int nextX = x + positionX[i];
            int nextY = y + positionY[i];
            if (!isBorder(nextX, nextY) && !vis[nextX][nextY] && map[nextX][nextY] == '.') {
                ans++;
                dfs(nextX, nextY);
            }
        }
    }

    static boolean isBorder(int x, int y) {
        return x < 0 || x == h || y < 0 || y == w;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }
}
